<!--
作者: 陈圳佳
日期: 2015/8/17
时间: 15:43
-->
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="../../commons/inc.jsp" %>
<ul class="breadcrumb">
    <li>销售管理</li>
    <li class="active">销售单历史</li>
</ul>
<!-- Modal -->
<div class="modal fade" id="details" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">
                    <span aria-hidden="true">&times;</span>
                    <span class="sr-only">Close</span>
                </button>
                <h6 class="modal-title" id="myModalLabel">销售单详情</h6>
            </div>
            <div class="modal-body">
                
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>
<div class="container">
    <div class="panel panel-info">
        <div class="panel-heading">
            <div id="search">
                <form class="form-inline" role="form">
                    <div class="form-group">
                        <div class="input-group">
                            <div class="input-group-addon">客户名称</div>
                            <input type="text" class="form-control input-sm" name="custom"
                                   id="custom">
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="input-group">
                            <div class="input-group-addon">操作人</div>
                            <input class="form-control input-sm" type="text" name="emp"
                                   id="emp">
                        </div>
                    </div>
                    <button type="submit" class="btn btn-info btn-sm">
                        <span class="glyphicon glyphicon-search"></span> 搜索
                    </button>
                    <a class="btn btn-inverse btn-sm" href="${ctx}/manage/sales/list/1.html" data-pjax="#content">
                        <span class="glyphicon glyphicon-refresh"></span> 重置
                    </a>
                    <a class="btn btn-primary btn-sm" href="${ctx}/manage/sales/edit.html" data-pjax="#content">
                        <span class="glyphicon glyphicon-plus"></span> 添加销售单
                    </a>
                </form>
            </div>
        </div>
        <div>
            <table class="table table-condensed table-striped table-hover table-bordered">
                <thead>
                <tr>
                    <th>序号</th>
                    <th>销售单编号</th>
                    <th>销售时间</th>
                    <th>客户名称</th>
                    <th>总金额</th>
                    <th>操作人</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <c:forEach items="${pageVo.data}" var="d">
                    <tr>
                        <td style="width: 60px">${d.id}</td>
                        <td>${d.code}</td>
                        <td><fmt:formatDate value="${d.sellDate}" timeStyle="yyyt-MM-dd"/></td>
                        <td>${d.customName}</td>
                        <td>${d.totalPrice}</td>
                        <td>${d.empName}</td>
                        <td class="btn-group-xs" width="150">
                            <button type="button" class="btn btn-info" onclick="showDetails('${d.id}')">
                                <span class="glyphicon glyphicon-eye-open"></span> 查看详情
                            </button>
                        </td>
                    </tr>
                </c:forEach>
                </tbody>
            </table>
            <div id="pagination" class="pagination pagination-sm">
                ${pageVo.pageNumHtml}
            </div>
        </div>
    </div>
</div>
<script>
    globalObj.callback = function () {
        $("#emp").val(getQueryString('emp'));
        $("#custom").val(getQueryString('custom'));
        $("#search").find("form").submit(function () {
            var vals = "?" + $(this).serialize();
            $.pjax({url: vals, container: '#content'});
            return false;
        });
    };
    function showDetails(id) {
        $.ajax({
            url: getMangePath() + "/sales/" + id,
            type: "GET",
            dataType: "json",
            success: function (resp) {
                $("#details").modal("show");
            }
        });
    }
</script>
